<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ question.question_text }} - 投票页面</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
        }
        
        :root {
            --primary: #4e54c8;
            --secondary: #8f94fb;
            --accent: #ff6b6b;
            --light: #f8f9fa;
            --dark: #343a40;
            --success: #28a745;
            --shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s ease;
        }
        
        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
            min-height: 100vh;
            padding: 20px;
            color: var(--dark);
            line-height: 1.6;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }
        
        .container {
            max-width: 800px;
            width: 100%;
            margin: 0 auto;
            padding: 30px;
        }
        
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }
        
        .logo {
            font-size: 1.8rem;
            font-weight: 700;
            background: linear-gradient(90deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .back-link {
            display: inline-flex;
            align-items: center;
            color: var(--primary);
            text-decoration: none;
            font-weight: 500;
            transition: var(--transition);
        }
        
        .back-link:hover {
            transform: translateX(-5px);
        }
        
        .back-link::before {
            content: '←';
            margin-right: 8px;
            font-weight: bold;
        }
        
        .card {
            background: white;
            border-radius: 16px;
            box-shadow: var(--shadow);
            overflow: hidden;
            transition: var(--transition);
            transform: translateY(0);
        }
        
        .card:hover {
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
        }
        
        .card-header {
            background: linear-gradient(90deg, var(--primary), var(--secondary));
            color: white;
            padding: 25px 30px;
            position: relative;
            overflow: hidden;
        }
        
        .card-header::after {
            content: '';
            position: absolute;
            top: -50px;
            right: -50px;
            width: 150px;
            height: 150px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 50%;
        }
        
        .card-header::before {
            content: '';
            position: absolute;
            bottom: -80px;
            left: -30px;
            width: 200px;
            height: 200px;
            background: rgba(255, 255, 255, 0.08);
            border-radius: 50%;
        }
        
        h1 {
            font-size: 1.8rem;
            position: relative;
            z-index: 2;
            text-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .card-body {
            padding: 35px 30px;
        }
        
        .error-message {
            background-color: #ffebee;
            color: #b71c1c;
            padding: 15px 20px;
            border-radius: 8px;
            margin-bottom: 25px;
            border-left: 4px solid #f44336;
            display: flex;
            align-items: center;
        }
        
        .error-message::before {
            content: '!';
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 24px;
            height: 24px;
            background: #f44336;
            color: white;
            border-radius: 50%;
            margin-right: 12px;
            font-weight: bold;
        }
        
        .voting-form {
            margin-top: 20px;
        }
        
        .form-group {
            margin-bottom: 25px;
        }
        
        .choice-item {
            display: flex;
            align-items: center;
            padding: 18px 20px;
            margin-bottom: 15px;
            border-radius: 10px;
            background-color: #f8f9ff;
            transition: var(--transition);
            border: 1px solid #e0e0e0;
            cursor: pointer;
        }
        
        .choice-item:hover {
            background-color: #edf0ff;
            border-color: var(--primary);
            transform: translateX(5px);
        }
        
        .choice-item.selected {
            background-color: #e8f5e9;
            border-color: #4caf50;
            box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
        }
        
        input[type="radio"] {
            display: none;
        }
        
        .custom-radio {
            display: inline-block;
            width: 24px;
            height: 24px;
            border: 2px solid #bdbdbd;
            border-radius: 50%;
            margin-right: 15px;
            position: relative;
            transition: var(--transition);
        }
        
        input[type="radio"]:checked + .custom-radio {
            border-color: var(--success);
            background-color: var(--success);
        }
        
        input[type="radio"]:checked + .custom-radio::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 12px;
            height: 12px;
            background: white;
            border-radius: 50%;
        }
        
        .choice-label {
            font-size: 1.1rem;
            font-weight: 500;
            color: var(--dark);
            flex: 1;
            cursor: pointer;
        }
        
        .submit-btn {
            display: block;
            width: 100%;
            background: linear-gradient(90deg, var(--primary), var(--secondary));
            color: white;
            padding: 16px;
            border-radius: 12px;
            text-decoration: none;
            font-weight: 600;
            transition: var(--transition);
            border: none;
            cursor: pointer;
            font-size: 1.1rem;
            box-shadow: 0 4px 10px rgba(78, 84, 200, 0.3);
            margin-top: 20px;
            position: relative;
            overflow: hidden;
        }
        
        .submit-btn::after {
            content: '✓';
            position: absolute;
            top: 50%;
            right: 20px;
            transform: translateY(-50%);
            font-size: 1.2rem;
            opacity: 0;
            transition: var(--transition);
        }
        
        .submit-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 7px 15px rgba(78, 84, 200, 0.4);
        }
        
        .submit-btn:hover::after {
            opacity: 1;
            transform: translateY(-50%) translateX(-10px);
        }
        
        .stats {
            display: flex;
            justify-content: space-between;
            margin-top: 30px;
            padding: 20px;
            background: rgba(143, 148, 251, 0.1);
            border-radius: 12px;
            font-size: 0.95rem;
            color: #495057;
        }
        
        .stats-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
            flex: 1;
        }
        
        .stats-value {
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--primary);
            margin-bottom: 5px;
        }
        
        .stats-label {
            font-size: 0.9rem;
            color: #6c757d;
        }
        
        .footer {
            text-align: center;
            margin-top: 40px;
            color: #6c757d;
            font-size: 0.9rem;
            padding: 20px;
        }
        
        .progress-bar {
            height: 6px;
            background: #e0e0e0;
            border-radius: 3px;
            overflow: hidden;
            margin-top: 10px;
        }
        
        .progress {
            height: 100%;
            background: linear-gradient(90deg, var(--primary), var(--secondary));
            border-radius: 3px;
            width: 0;
            transition: width 1s ease;
        }
        
        @media (max-width: 600px) {
            .container {
                padding: 20px 15px;
            }
            
            .card-header {
                padding: 20px;
            }
            
            .card-body {
                padding: 25px 20px;
            }
            
            .stats {
                flex-direction: column;
                gap: 15px;
            }
            
            h1 {
                font-size: 1.5rem;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="logo">投票系统</div>
            <a href="{% url 'polls:index' %}" class="back-link">返回投票首页</a>
        </div>
        
        <div class="card">
            <div class="card-header">
                <h1>{{ question.question_text }}</h1>
            </div>
            
            <div class="card-body">
                <form action="{% url 'polls:vote' question.id %}" method="post" class="voting-form">
                    {% csrf_token %}
                    
                    {% if error_message %}
                        <div class="error-message">
                            <strong>{{ error_message }}</strong>
                        </div>
                    {% endif %}
                    
                    <div class="form-group">
                        {% for choice in question.choice_set.all %}
                            <div class="choice-item" onclick="selectChoice(this)">
                                <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}">
                                <span class="custom-radio"></span>
                                <label for="choice{{ forloop.counter }}" class="choice-label">{{ choice.choice_text }}</label>
                            </div>
                        {% endfor %}
                    </div>
                    
                    <button type="submit" class="submit-btn">提交投票</button>
                </form>
            </div>
        </div>
        
        <div class="stats">
            <div class="stats-item">
                <div class="stats-value">86%</div>
                <div class="stats-label">参与率</div>
                <div class="progress-bar">
                    <div class="progress" style="width: 86%"></div>
                </div>
            </div>
            <div class="stats-item">
                <div class="stats-value">100</div>
                <div class="stats-label">总投票数</div>
                <div class="progress-bar">
                    <div class="progress" style="width: 72%"></div>
                </div>
            </div>
            <div class="stats-item">
                <div class="stats-value">24h</div>
                <div class="stats-label">投票开放时间</div>
                <div class="progress-bar">
                    <div class="progress" style="width: 65%"></div>
                </div>
            </div>
        </div>
        
        <div class="footer">
            <p>© 2025 投票系统 | 您的意见对我们很重要</p>
        </div>
    </div>
    
    <script>
        // 选择选项时添加视觉反馈
        function selectChoice(element) {
            // 移除之前的选择
            document.querySelectorAll('.choice-item').forEach(item => {
                item.classList.remove('selected');
            });
            
            // 添加当前选择
            element.classList.add('selected');
            
            // 选中对应的单选按钮
            const radio = element.querySelector('input[type="radio"]');
            radio.checked = true;
        }
        
        // 初始加载时检查已选择的选项
        document.addEventListener('DOMContentLoaded', function() {
            const selectedRadio = document.querySelector('input[type="radio"]:checked');
            if (selectedRadio) {
                selectedRadio.closest('.choice-item').classList.add('selected');
            }
        });
        
        // 添加进度条动画
        document.querySelectorAll('.progress').forEach(progress => {
            // 保存原始宽度
            const width = progress.style.width;
            // 重置为0
            progress.style.width = '0';
            
            // 设置延迟动画
            setTimeout(() => {
                progress.style.width = width;
            }, 300);
        });
    </script>
</body>
</html>